﻿<style type="text/css" media=print> 
.noprint{display : none } 
</style> 

<div style="width:190px;font-size:12px">
   <div style="text-align:center;line-height:20px">
	<span style="font-size:18px"><strong>V客30</strong><span style="font-size:14px">(臣田分店)</span></span>
   </div>
   <div  style="text-align:center;line-height:20px">
       <span style="font-size:15px">www.vk30.com</span>
   </div>
   <div  style="text-align:center;line-height:20px">
	<span id="orderno"></span> 
   </div>
   <div  style="text-align:left;line-height:20px;padding-left:10px">
	<span style="width:75px;float:left">品名/条码</span>
	   <span style="width:28px">数量</span>
       <span style="width:28px">单价</span>     
       <span style="width:28px">金额</span>
    </div>
   <div style="text-align:center;line-height:10px">
	<span style="font-size:12px">----------------------------------------------</span>
   </div>
   <div id="goods"></div>

   <div style="text-align:center;line-height:10px">
	<span style="font-size:12px">----------------------------------------------</span>
   </div>
   <div style="text-align:right;line-height:20px;padding-right:10px">
	   <span id="timer"  style="width:80px;text-align:left"></span> <span id="price"  style="width:90px;text-align:right;"></span>
   </div>
    <div id='address' style="text-align:left;line-height:20px;padding-left:10px">	  
   </div>
   <div id="name" style="text-align:left;line-height:20px;padding-left:10px">
   </div>
    <div id="tel" style="text-align:left;line-height:20px;padding-left:10px">	  
   </div>
</div> 
 <div class="noprint" style="text-align:left;padding-top:10px;padding-left:80px">
   <input type="button" style="height:40px;width:80px" value="关 闭" onclick="window.opener=null;window.open('','_self');window.close();"/> </div>
<script>
var order=opener.printorder.order;
var details=opener.printorder.orderDetail;
//document.body.innerHTML=opener.printhtml;
var printhtml='';
 for(i=0;i<details.length;i++)
        {
         var detail=details[i];
         printhtml=printhtml+'<div style="text-align:left;line-height:20px;padding-left:10px">';
         printhtml=printhtml+'<span>'+(i+1)+' &nbsp;'+detail.name+'</span>';
         printhtml=printhtml+'</div>';
         printhtml=printhtml+'<div style="text-align:left;line-height:20px;padding-left:10px">';
         printhtml=printhtml+'<span style="width:75px;float: left;">'+detail.goodsno+'</span>';
         if(detail.kind=='0')
         {
         printhtml=printhtml+'<span style="width:25px;text-align:center">'+detail.num+'</span>';
         printhtml=printhtml+'<span style="width:35px;text-align:center">'+detail.price+'</span>';      
         printhtml=printhtml+'<span style="width:35px;text-align:center">'+detail.totalprice+'</span>';
         }
         else if(detail.kind=='1')
         {  
         printhtml=printhtml+'<span style="width:25px;text-align:center">'+detail.num+'</span>';
         printhtml=printhtml+'<span style="width:70px;text-align:center">(积分兑换)</span>';
         }
         printhtml=printhtml+'</div>';
       }
if(order.yf>0)
{
  printhtml=printhtml+'<div style="text-align:left;line-height:20px;padding-left:10px">';
  printhtml=printhtml+'<span>'+(details.length+1)+' &nbsp;运费</span>';
  printhtml=printhtml+'</div>';
  printhtml=printhtml+'<div style="text-align:left;line-height:20px;padding-left:10px">';
  printhtml=printhtml+'<span style="width:75px;float: left;">0000000000000</span>';
  printhtml=printhtml+'<span style="width:25px;text-align:center">1</span>';
  printhtml=printhtml+'<span style="width:35px;text-align:center">'+format_number(order.yf,1)+'</span>';      
  printhtml=printhtml+'<span style="width:35px;text-align:center">'+format_number(order.yf,1)+'</span>';
  printhtml=printhtml+'</div>';
}
document.getElementById("goods").innerHTML=printhtml;   
document.getElementById("orderno").innerHTML='订单号：'+order.orderno; 
var totalprice=order.price*1+order.yf*1;

document.getElementById("price").innerHTML='总金额: '+format_number(totalprice,1);  
document.getElementById("address").innerHTML='送货地址:'+order.address;      
document.getElementById("name").innerHTML='收货人:'+order.relname; 
document.getElementById("tel").innerHTML='电话:'+order.tel; 
var today=new Date(); 
document.getElementById("timer").innerHTML=today.getYear()+"-"+(today.getMonth()+1)+"-"+today.getDate();
window.print();


function format_number(pnumber,decimals){
    if (isNaN(pnumber)) { return 0};    
    if (pnumber=='') { return 0};    
    var snum = new String(pnumber);    
    var sec = snum.split('.');    
    var whole = parseFloat(sec[0]);    
    var result = '';    
    if(sec.length > 1){        
    var dec = new String(sec[1]);        
    dec = String(parseFloat(sec[1])/Math.pow(10,(dec.length - decimals)));        
    dec = String(whole + Math.round(parseFloat(dec))/Math.pow(10,decimals));        
    var dot = dec.indexOf('.');        
    if(dot == -1){            
       dec += '.';            
       dot = dec.indexOf('.');       
        }        
     while(dec.length <= dot + decimals) { dec += '0'; }        
     result = dec;    
     } else
     {        
     var dot;        
     var dec = new String(whole);        
     dec += '.';        
     dot = dec.indexOf('.');       
      while(dec.length <= dot + decimals) { dec += '0'; }        
      result = dec;    
      }    
     return result;
   }
     /***   Usage:  format_number(12345.678, 2);*   result: 12345.68**/
</script>

